package com.itheima.chapter02.domain;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;

@Component  // Spring容器会把当前类实例成对象consumer，保存在容器中
public class Consumer2 {
//    @Value("${consumer.username}")
    private String username;
//    @Value("${consumer.age}")
    private int age;
//    @Value("#{'${consumer.hobby}'.split(',')}")
    private String[] hobby;
//    @Value("${consumer.subject}")
    private List subject;

    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String[] getHobby() {
        return hobby;
    }
    public void setHobby(String[] hobby) {
        this.hobby = hobby;
    }
    public List getSubject() {
        return subject;
    }
    public void setSubject(List subject) {
        this.subject = subject;
    }
    @Override
    public String toString() {
        return "Consumer{" +
                "username='" + username + '\'' +
                ", age=" + age +
                ", hobby=" + Arrays.toString(hobby) +
                ", subject=" + subject +
                '}';
    }
}
